<?php
/**
 +------------------------------------------------------------------------------
 * ShowAction控制器类
 +------------------------------------------------------------------------------
 * @category   view
 * @package  index
 * @subpackage  index
 * @author   朝闻道 <hydata@gmail.com>
 * @date 2010-8-24
 * @time  上午10:18:40
 +------------------------------------------------------------------------------
 */
class ShowAction extends CommonAction{
	/**
	   *查看信息详情
	   *@date 2010-8-24
	   *@time 下午02:59:58
	   */
	function index() {
		//查看信息详情
		$id=Input::getVar($_GET['id']);
		$dao=D("Arc");
		$condition=array();
		$condition['is_show']=1;
		$condition['id']=$id;
		$data=$dao->where($condition)->find();
		$olang='';
		if($data['olang']){
			if(strpos($data['olang'],',')){
				$olang=explode(',', $data['olang']);
				if(in_array($this->lang,$olang)){
					$olang=$this->lang;
				}else{
					$this->error(L("_not_lang_db_"));
				}
			}elseif($this->lang==$data['olang']){
				$olang=$this->lang;
			}else{
				$this->error(L("_not_lang_db_"));
			}
		}else{
			$this->error(L("_not_lang_db_"));
		}
		parent::clickorshow($data);
		parent::iicstat($data);
		//处理标题
		$data['title']=$data[$this->plang['l'].'name'];
		
		//获取指定语言的其他信息
		$ext_lang=D("ArcLang");
		$data['_lang']=$ext_lang->where("aid=$id and lang='$this->lang'")->find();
		//dump($data);
		unset($dao);

		//获取深度链接
		$condition=array();
		$condition['aid']=$id;
		$condition['dlang']=$this->lang;
		$deep=D("Deep");
		$data['_deep']=$deep->where($condition)->findAll();
		
		//获取产品
		$condition=array();
		$condition['aid']=$id;
		$condition['plang']=$this->lang;
		$product=D("Product");
		$data['_product']=$product->where($condition)->findAll();
		
		//获取新闻
		$condition=array();
		$condition['aid']=$id;
		$condition['nlang']=$this->lang;
		$news=D("News");
		$data['_news']=$news->where($condition)->findAll();
		
		//获取扩展资料
		$condition=array();
		$condition['aid']=$id;
		$condition['elang']=$this->lang;
		$ext=D("Ext");
		$data['_ext']=$ext->where($condition)->findAll();
		
		//获取相册资料
		$condition=array();
		$condition['aid']=$id;
		$condition['alang']=$this->lang;
		$album=D("Album");
		$alb=$album->where($condition)->findAll();
		$pic=D("Pic");
		if($alb){
			$arr=array();
			foreach ($alb as $k=>$v){
				$arr[$k]=$v;
				$arr[$k]['pic']=$pic->where("album_id={$v['id']}")->order("cover DESC")->find();
			}
			$alb=$arr;
		}
		$data['_album']=$alb;
		
		//获取相册以外的图片
		$condition=array();
		$condition['aid']=$id;
		$condition['xid']=0;
		$condition['album_id']=0;
		$condition['xtype']='arc';
		$condition['plang']=$this->lang;
		$data['_pic']=$pic->where($condition)->findAll();
		$data['cover']='';
		if($data['_pic']){
			foreach ($data['_pic'] as $p){
				if($p['cover']=='1'){
					$data['cover']=$p['filepath'].'s_'.$p['filename'];
				}
			}
		}
		$this->assign("info",$data);
		$this->assign('dh',$this->cat_dh($data['cid'],$this->plang['l']));
		
		$this->display();
	}//end index
	
	/**
	   *跳转到指定页面
	   *@date 2010-8-24
	   *@time 下午03:00:26
	   */
	function jump() {
		//跳转到指定页面
		$url=mydecode($_GET['url']);
		if(strpos("||", $url)){
			$url=explode('||',$url);
			$url=$url['0'];
			parent::update_click($url['2'],$url['1']);
		}
		redirect($url);
	}//end jump
}//end ShowAction